package cn.song.order;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;


@EnableDiscoveryClient // 开启微服务注册功能
@EnableFeignClients(basePackages = "co.song.feign.clients") // 开启Feign的功能(Feign替代RestTemplate)
@MapperScan("cn.song.order.mapper")
@SpringBootApplication
public class OrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
    }


    @Bean
    // @LoadBalanced // 开启负载均衡
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }


    /**
     * 自定义负载均衡策略
     *
     * @return irule
     */
    // @Bean
    // public IRule randomRule(){
    //     return new RandomRule();
    // }
}
